define(['jquery'],function($){
		  
	return {
       jiexi : function(dat){
//  -----------------------轮播图-----------------------------------
        	var $div = $('#banner');
			    var $ul = $('.ban');

        	var info = dat.data.act_info;

        	for(var i=0; i < 1; i++){
        		var objArr = info[i].act_rows;

        		for(var group of objArr){
        			var imgUrl = group.activity.img;

        			for(var i=0;i<objArr.length;i++){
        				var $li = $('<li></li>');
						var $img = $('<img>').attr('src',imgUrl);
        			}
        			$li.append($img);
					$ul.append($li);
        		}
        	}
        	lunbo(objArr);

//      	商标
			for(var i=3;i<4;i++){
				var picArr = info[i].act_rows;
				for(var group of picArr){
					var imgUrl = group.activity.img;
					for(var i=0;i<picArr.length;i++){
						var $li =  $('<li></li>').appendTo('.brand');
						var $img = $('<img>').attr('src',imgUrl);
					}
					$li.append($img);
				}
			}

//			便利店
			for(var i=4;i<5;i++){
				var picArr = info[i].act_rows;
				console.log(picArr);
				for(var group of picArr){
					if(group.type == 'chead'){
						var first_img = group.act_rows[0].chead_detail.img;
						var $li = $('<li></li>').css('background','url(' + first_img + ') no-repeat').appendTo('.sub_pic');
						$li.css('backgroundSize','100% 100%');
					}
					else if(group.type == 'cactivity'){
						for(var part of group.act_rows){
							var img = part.cactivity_detail.img;
							var $li = $('<li></li>').css('background','url(' + img + ') no-repeat').appendTo('.sub_pic');
							$li.css('backgroundSize','100% 100%');
						}
					}
					else if(group.type == 'cicons'){
						for(var part of group.act_rows){
							var img = part.cicons_detail.img;
							var name = part.cicons_detail.name;
							var $li = $('<li></li>').attr('class','sub_icon').css('background','url(' + img + ') no-repeat center').appendTo('.sub_pic');
							$li.css('backgroundSize','95% 95%');
							var $a = $('<a></a>').text(name).appendTo($li);	
						}
					}
					else if(group.type == 'cscene'){
						for(var part of group.act_rows){
							var img = part.cscene_detail.img;
							var $li = $('<li></li>').appendTo('.sub_food');
							var $img = $('<img />').attr('src',img).appendTo($li);
						}
					}
				}	
			}	

//		优选水果
			for(var i=5;i<6;i++){
				var picArr = info[i].act_rows;
				for(var group of picArr){
					var obj = group.category_detail;
					var objPic = group.activity.img;
					var name = obj.name;

					var $li = $('<li></li>').attr('class','shuiGuo').appendTo('.food_ul');
					var $div_title = $('<div></div>').attr('class','title').appendTo($li);
					var $div_pic = $('<div></div>').attr('class','pic_list').appendTo($li);
					var $img_big = $('<img />').attr('src',objPic).appendTo($div_pic);
					var $ul = $('<ul></ul>').attr('class','cate_list').appendTo($li);
					var $span = $('<span></span>').attr('class','name').text(name).appendTo($div_title);
					var $span = $('<span></span>').attr('class','more').text('更多 >').appendTo($div_title);
					for(var part of obj.goods){
						var imgUrl = part.img;
						var long_name = part.long_name;
						var old_price = part.market_price;
						var new_price = part.partner_price;
						var weight = part.specifics;

						var $li_small = $('<li></li>').appendTo($ul);
						var $div = $('<div></div>').attr('class','pic').appendTo($li_small);
						var $div_con = $('<div></div>').attr('class','con').appendTo($li_small);
						var $img = $('<img />').attr('src',imgUrl).appendTo($div);
						var $p = $('<p></p>').attr('class','des').text(long_name).appendTo($div_con);
						var $span = $('<span></span>').attr('class','jingXuan').text('精选').appendTo($div_con);
						var $p = $('<p></p>').attr('class','weight').text(weight).appendTo($div_con);
						var $p_price = $('<p></p>').appendTo($div_con);
						var $span = $('<span></span>').attr('class','new_price').text('¥'+new_price).appendTo( $p_price);
						var $span = $('<span></span>').attr('class','old_price').text('¥'+old_price).appendTo( $p_price)
						var $p_tianjia = $('<p></p>').appendTo($div_con);
						var $span = $('<span></span>').attr('class','tianjia').appendTo($p_tianjia);
					}
				}

			}
	        function lunbo(objArr){
	        	var $div = $('#banner');
				    var $ul = $('.ban');
	
	        	var $w = $div.width();
						$ul.css('width',$w * objArr.length);
						var $index = 0;
						function nextFn(){
							$index++;
							if($index > objArr.length-1){
								$index = 0;
							}
							$ul.css('left',$index * $w * -1);
						}
						function clearTime(){
							clearInterval($timer);
							$timer = setInterval(nextFn,3000);
						}
						var $timer = setInterval(nextFn,3000);
			    }
		    }
       
      //加入购物车操作：

//    	var tianjia = document.querySelector('.tianjia');
//      var num = 0;
//    	tianjia.onclick = function(){
//    		num++;
//    		$(.car_num).text(num);
//    	}
       
      
	}
})
